# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# LLVM libc unittest library.

load("//libc:libc_build_rules.bzl", "libc_support_library")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

libc_support_library(
    name = "test_logger",
    srcs = ["TestLogger.cpp"],
    hdrs = ["TestLogger.h"],
    deps = [
        "//libc:__support_cpp_string",
        "//libc:__support_cpp_string_view",
        "//libc:__support_osutil_io",
        "//libc:__support_uint128",
    ],
)

libc_support_library(
    name = "LibcUnitTest",
    srcs = [
        "BazelFilePath.cpp",
        "ExecuteFunctionUnix.cpp",
        "LibcTest.cpp",
        "LibcTestMain.cpp",
    ],
    hdrs = [
        "ErrnoSetterMatcher.h",
        "ExecuteFunction.h",
        "LibcTest.h",
        "PlatformDefs.h",
        "Test.h",
    ],
    deps = [
        ":test_logger",
        "//libc:__support_c_string",
        "//libc:__support_cpp_bit",
        "//libc:__support_cpp_bitset",
        "//libc:__support_cpp_span",
        "//libc:__support_cpp_string",
        "//libc:__support_cpp_string_view",
        "//libc:__support_cpp_type_traits",
        "//libc:__support_fputil_fp_bits",
        "//libc:__support_fputil_fpbits_str",
        "//libc:__support_fputil_rounding_mode",
        "//libc:__support_macros_properties_architectures",
        "//libc:__support_stringutil",
        "//libc:__support_uint128",
        "//libc:errno",
        "//llvm:Support",
    ],
)

libc_support_library(
    name = "fp_test_helpers",
    srcs = [
        "FPExceptMatcher.cpp",
        "RoundingModeUtils.cpp",
    ],
    hdrs = [
        "FPExceptMatcher.h",
        "FPMatcher.h",
        "RoundingModeUtils.h",
    ],
    deps = [
        ":LibcUnitTest",
        ":string_utils",
        "//libc:__support_cpp_bit",
        "//libc:__support_cpp_bitset",
        "//libc:__support_cpp_span",
        "//libc:__support_cpp_type_traits",
        "//libc:__support_fputil_fenv_impl",
        "//libc:__support_fputil_fp_bits",
        "//libc:__support_fputil_fpbits_str",
        "//libc:__support_fputil_rounding_mode",
    ],
)

libc_support_library(
    name = "memory_matcher",
    srcs = [
        "MemoryMatcher.cpp",
    ],
    hdrs = [
        "MemoryMatcher.h",
    ],
    deps = [
        ":LibcUnitTest",
        "//libc:__support_cpp_bit",
        "//libc:__support_cpp_bitset",
        "//libc:__support_cpp_span",
        "//libc:__support_cpp_type_traits",
    ],
)

libc_support_library(
    name = "printf_matcher",
    srcs = [
        "PrintfMatcher.cpp",
    ],
    hdrs = [
        "PrintfMatcher.h",
    ],
    deps = [
        ":LibcUnitTest",
        ":string_utils",
        "//libc:__support_fputil_fp_bits",
        "//libc:printf_core_structs",
    ],
)

libc_support_library(
    name = "string_utils",
    hdrs = [
        "StringUtils.h",
    ],
    deps = [
        "//libc:__support_cpp_string",
        "//libc:__support_cpp_type_traits",
    ],
)
